package com.dlb.andorid.activity;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dlb.andorid.R;
import com.kwan.xframe.mvp.presenter.BasePresenter;
import com.kwan.xframe.mvp.view.activity.BaseCommonActivity;

import java.util.ArrayList;
import java.util.List;

public class MyCommentActivity extends BaseCommonActivity {

	@Override
	protected BasePresenter getBasePresenter() {
		return null;
	}

	@Override
	protected void initData() {

	}

	@Override
	protected int getTopViewId() {
		return 0;
	}

	@Override
	protected int getMainViewId() {
		return R.layout.activity_my_comment;
	}

	@Override
	protected int getBottomViewId() {
		return 0;
	}

	@Override
	protected String getTitleTxt() {
		return "我的评价";
	}

	@Override
	public String getPageName() {
		return null;
	}

	private View rl_indicator1, rl_indicator2;
	private View v_indicator1, v_indicator2;

	private RecyclerView recycleView;
	private BaseQuickAdapter<String, BaseViewHolder> mAdapter1, mAdapter2;
	private List<String> mData1 = new ArrayList<>();
	private List<String> mData2 = new ArrayList<>();


	@Override
	protected void initViews() {
		super.initViews();

		rl_indicator1 = findViewById(R.id.rl_indicator1);
		rl_indicator2 = findViewById(R.id.rl_indicator2);

		v_indicator1 = findViewById(R.id.v_indicator1);
		v_indicator2 = findViewById(R.id.v_indicator2);

		rl_indicator1.setOnClickListener(this);
		rl_indicator2.setOnClickListener(this);

		for (int i=0;i<10;i++)
			mData1.add("");

		for (int i=0;i<4;i++)
			mData2.add("");

		mAdapter1 = new BaseQuickAdapter<String, BaseViewHolder>(R.layout.list_item_comment, mData1) {
			@Override
			protected void convert(BaseViewHolder helper, String item) {

			}

		};

		mAdapter2 = new BaseQuickAdapter<String, BaseViewHolder>(R.layout.list_item_comment2, mData2) {
			@Override
			protected void convert(BaseViewHolder helper, String item) {

			}

		};
		recycleView = findViewById(R.id.recycleView);
		recycleView.setLayoutManager(new LinearLayoutManager(this));
		recycleView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
		recycleView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
		recycleView.setHasFixedSize(true);

		//解决更新 闪烁
		recycleView.setItemAnimator(null);
		recycleView.setNestedScrollingEnabled(false);
		recycleView.setAdapter(mAdapter1);

	}

	@Override
	public void onClick(View v) {
		super.onClick(v);

		if (v == rl_indicator1) {
			v_indicator1.setVisibility(View.VISIBLE);
			v_indicator2.setVisibility(View.INVISIBLE);

			recycleView.setAdapter(mAdapter1);

		} else if (v == rl_indicator2) {
			v_indicator2.setVisibility(View.VISIBLE);
			v_indicator1.setVisibility(View.INVISIBLE);

			recycleView.setAdapter(mAdapter2);
		}

	}
}
